// pages/my/my.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    that.loadings();
    that.setData({
      url: app.globalData.imgUrl,
    })
    wx.getUserInfo({
      success: function(res) {
        console.log(res.userInfo)
        var userInfo = res.userInfo;
        that.setData({
          nickName: userInfo.nickName,
          avatarUrl: userInfo.avatarUrl,
        })
      }
    })
  },
  loadings: function() {
    var that = this;
    wx.request({
      url: app.globalData.baseUrl + 'doctor/member/detail',
      data: {

      },
      header: {
        'sign': app.globalData.sign,
        'token': app.globalData.token,
        'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
      },
      method: 'POST',
      success: function(t) {
        console.log("医生端个人中心", t);
        // wx.hideLoading();
        that.setData({
          core: t.data.data[0],
          name: t.data.data[0].name,
          headPic: t.data.data[0].headPic,
          mobile: t.data.data[0].mobile,
        })
      }
    })
  },
  gosystem: function() {
    var mobile = this.data.mobile;
    wx.navigateTo({
      url: '../user-my-setup/user-my-setup?mobile=' + mobile,
    })
  },
  //跳转
  beautyValue: function() {
    wx.navigateTo({
      url: '../user-my-rank/user-my-rank',
    })
  },
  beautyCoin: function() {
    var userid = wx.getStorageSync('userid');
    wx.navigateTo({
      url: '../doctor-my-task/doctor-my-task?id=' + userid,
    })
  },
  onShareAppMessage: function () {
    return {
      title: '分享好友获取美丽币！',
      path: '/pages/index/index',
      // imageUrl: '/pages/images/aa.jpg',
      success: function () {
        wx.request({
          url: app.globalData.baseUrl + 'doctor/memberTaskApi/addBeauty',
          data: {
            userId: wx.getStorageSync('userid'),
            type: 3
          },
          header: {
            'sign': app.globalData.sign,
            'token': app.globalData.token,
            'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
          },
          method: 'POST',
          success(res) {
            console.log('分享给美丽币给美丽值', res);
          }
        })
      }
    }
  }
})